import Mock from 'mockjs2';

const Random = Mock.Random;

Mock.mock('/api/login', 'post', (option) => {
    let { phone, password } = JSON.parse(option.body);
    if(phone !== '13011112222' || password !== '123456'){
        return {
            status: 202,
            message: '账号或密码错误',
        }
    }
    return {
        status: 200,
        message: '登录成功',
        token: '1123'
    }
})

Mock.mock('/api/userInfo', (option) => {
    let token = localStorage.getItem('token');
    if(!token){
        return {
            status: 202,
            message: '获取用户信息失败'
        }
    }
    return {
        status: 200,
        message: '获取用户信息成功',
        data: {
            name: '吐槽电视机',
            phone: '13011112222',
            auth: 'admin'
        }
    }
})